// pages/findCamp/findCamp.js
import{searchName} from"../../api/index"
Page({

  /**
   * 页面的初始数据
   */
  data: {
    value: '',
    hotSearch:[
      {id:1,name:"帐篷营地"},
      {id:2,name:"综合营地"},
      {id:3,name:"接待房车"},
      {id:4,name:"教育研学"},
    ],
    searchHistory:[],
    campItemList:[],//搜索结果
  },
  //确定搜索时触发
  async onSearch() {
    wx.showLoading({
      title: '正在检索中',
      mask:true
    })
      const result=await searchName(this.data.value);
      console.log(result)
      if(result.code==200){
       const list= result.data.map(item=>{
          item.imageUrl=item.imageUrl.split(",")
          item.introduce=item.introduce.substring(0,50)
          return item;
        })
        this.setData({
          campItemList:list
        })
       
      }
      wx.hideLoading()
     
  },

 


  /**
   * 生命周期函数--监听页面加载
   */
  onLoad(options) {
  
  },

})